<template>
  <div id="user-header">
    <h2>博 客 后 台</h2>
    <span @click="logout">注销</span>
  </div>
</template>

<script>
export default {
  name: "UserHeader",
  methods: {
    logout() {
      this.$store.commit("logout");
      this.$router.replace("/blogs");
    }
  }
}
</script>

<style scoped>
  #user-header {
    height: 50px;
    line-height: 50px;
    background: rgba(0, 0, 0, 0.9);
  }

  h2 {
    color: white;
    font-size: 2em;
    text-align: center;
  }

  #user-header span {
    position: absolute;
    top: 0;
    right: 0;
    padding: 0 20px;
    color: black;
    font-weight: bold;
    background-color: white;
  }

  #user-header span:hover {
    cursor: pointer;
    background-color: #eeeeee;
  }
</style>